/*
 * @lc app=leetcode.cn id=806 lang=cpp
 *
 * [806] 写字符串需要的行数
 */

// @lc code=start
class Solution
{
public:
  vector<int> numberOfLines(vector<int>& widths, string s)
  {
    int n = s.size();
    int row = 1, width = 0;
    for (char& c : s) {
      width += widths[c - 97];
      if (width > 100) {
        ++row;
        width = widths[c - 97];
      }
    }
    return {row, width};
  }
};
// @lc code=end
